<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0036)http://user.huway.com/uc/msg/private -->
<html xmlns="http://www.w3.org/1999/xhtml">
<style type="text/css" id="974728359498"></style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>中华户外网-私信消息</title>
	<jsp:include page="personcommonref.jsp"></jsp:include>
</head>

<body id="user">
	<div class="user_cover_bg"></div>
	<!--user box begin-->
	<div class="user_box">
		<%--	公共头部	 --%>
		<jsp:include page="indexHead.jsp"></jsp:include>

		<%--	个人信息公共	begin --%>
		<!--banner begin-->
		<div class="banner_box">
		    <img src="../images/user_banner1.jpg" />
		</div>
		<!--banner end-->
		
		<div class="user_info_box clearfix">
			<div class="user_box_lt">
		    <div class="user_box_lt_bg"></div>
		    <div class="user_box_lt_cont">
		        <div class="user_box_lt_top">
		            <div class="user_box_lt_header">
		                <img src="${session.user.headImg }">
		                <h4>
		                	${session.user.nickName}
		                    <img src="../images/user_focus_b.png">
		                </h4>
		            </div>
		
		        </div>
		        <ul>
		            <li ><a href="personinfo.jsp">我的个人资料</a></li>
		            <li><a href="PostAction_personPost.action">我的发帖</a></li>
		            <li><a href="personreply.jsp">我的回复</a></li>
		            <li><a href="personcollect.jsp">我的收藏</a></li>
		            <li><a href="personfocus.jsp">我的关注</a></li>
		            <li class="user_left_current"><a href="personmsglist.jsp">我的消息</a></li>
		            <li><a href="personhome.jsp">我的主页</a></li>
		        </ul>
		    </div>
		</div>
		<link type="text/css" href="../css/personinfo/setup.css" rel="stylesheet">
		<script type="text/javascript" src="../js/personinfo/select.js"></script>
		<%--	个人信息公共	end  --%>
				<c:if test="${fn:length(page.queryResult) == 0 }">
                	<div style="font-size: 16px;color:#666;line-height: 30px;text-align: center;margin-top: 50px">
                		<p>您还没有消息记录噢~</p>
                	</div>
                </c:if>
                <c:if test="${fn:length(page.queryResult) > 0 }">
				<div class="user_box_rg">
					<div class="user_collect">
						<div class="user_private_box">
							<ul id="infolist">
								<li msgid="12641" cate="0" sender="1273466"
									style="border: 1px solid rgb(255, 255, 255);">
									<div class="fl">
										<img src="./中华户外网-私信消息_files/read.png">
									</div>
									<div class="txt">
										<p>喂喂喂</p>
										<p>
											来自<span>建辉</span>2016-05-02 15:58:34
										</p>
									</div>
									<div class="status">
										<p class="status_red">已读</p>
									</div>
									<div class="btn">
										<span class="delete" msgid="12641" touid="1273466"
											style="background-image: url(http://cdn.huway.com/ucstatic/static/web/images/user_order_delete.png?v=1.0);"></span>
										<a
											href="http://user.huway.com/uc/msg/plist?plid=12641&sender=1273466">回复</a>
									</div></li>

							</ul>
							<input type="hidden" id="page" name="page" value="1"> <input
								type="hidden" id="type" name="type" value="2">
						</div>


					</div>

				</div>
				</c:if>
				<!-- footer end-->
				<script type="text/javascript">
    $(function(){
        reloadHover();
        function reloadHover() {
            $(".user_private_box").find("li").hover(function () {
                $(this).css('border', '1px solid #f1a400');
                $(this).find('.btn span').css("background-image", "url(http://cdn.huway.com/ucstatic/static/web/images/user_order_delete_hover.png?v=1.0)");
            }, function () {
                $(this).css('border', '1px solid #fff');
                $(this).find('.btn span').css("background-image", "url(http://cdn.huway.com/ucstatic/static/web/images/user_order_delete.png?v=1.0)");
            });
        }

        $(document).on('click',".user_private_box li",function(event){
            var msgid = $(this).attr("msgid");
            var cate = $(this).attr("cate");
            var sender = $(this).attr("sender");
            var objimg = $(this).children(".fl").children("img");
            var objstatus = $(this).children(".status");
            if(cate == 0 ){
                location.href = 'http://user.huway.com/uc/msg/plist?plid='+msgid+'&sender='+sender;
                return false;
            }
            $.ajax({
                type: "POST",
                url: "/uc/msg/doneread",
                data:{mid:msgid,type:2},
                dataType: "json",
                success: function(data){
                    if(data.status == 2000){
                        objimg.attr("src","http://cdn.huway.com/ucstatic/static/web/images/read.png?v=1.0");
                        objstatus.html("<p class='status_red'>已读</p>");
                        location.href = 'http://user.huway.com/uc/msg/plist?plid='+msgid+'&sender='+sender;
                    }else{
                        alert(data.message);
                    }
                }
            });
            event.stopPropagation();
        })

        $("#more").click(function(){
            var objdiv = $(this);
            $.get('/uc/msg/nextpage?type=2&page='+$("#page").val(),function(data){
                $("#page").val(data.page);
                if(data.more == '2'){
                    objdiv.html('没有更多了').unbind();
                }
                var html = '';
                $.each(data.msginfos, function(infos, info){
                    html += '<li msgid="'+info.pmid
                            +'" cate="'+ info.new
                            +'" sender="'+info.send_uid
                            +'"><div class="fl"><img src="';
                    if(info.new == 1){
                        html += 'http://cdn.huway.com/ucstatic/static/web/images/unread.png?v=1.0';
                    }else{
                        html += 'http://cdn.huway.com/ucstatic/static/web/images/read.png?v=1.0';
                    }
                        html +='" /></div><div class="txt"><p>'+info.lastmessage
                                +'</p><p>来自<span>'+info.send_username
                                +'</span>'+ getLocalTime(info.dateline)
                                +'</p></div><div class="status">';
                            if(info.new == 1){
                                html += '<p class="status_unred">未读</p>';
                            }else{
                                html += '<p class="status_red">已读</p>';
                            }
                        html +='</div><div class="btn"><span class="delete" msgid="'+info.pmid
                                +'" touid="' +info.send_uid
                                +'"></span><a href="http://user.huway.com/uc/msg/plist?plid='+info.pmid
                                +'&sender='+info.send_uid
                                +'">回复</a></div></li>';
                });
                $("#infolist").append(html);
                reloadHover();

            });

        });

        $(document).on('click','.delete',function(event){
            var msgid = $(this).attr("msgid");
            var touid = $(this).attr("touid");
            var obj = $(this).parent(".btn").parent("li");
            if(!confirm('确定是否删除')){
                return false;
            }
            $.ajax({
                type: "POST",
                url: "/uc/msg/delplmsg",
                data:{plid:msgid,touid:touid},
                dataType: "json",
                success: function(data){
                    if(data.status == 2000){
                        obj.hide();
                    }else{
                        alert(data.message);
                    }
                }
            });
            event.stopPropagation();
        })

        $.get('/helper/unread/count',
            {},
            function(result) {
                if(result.status == 2000){
                    if(result.newpm > 0) {
                        $("#newsystem").html("(" + result.newpm + ")");
                    }
                    if(result.newprivatepm > 0) {
                        $("#newprivate").html("(" + result.newprivatepm + ")");
                    }
                    if(result.newnotice > 0)
                    {
                        $("#newnotice").html("(" + result.newnotice + ")");
                    }
                }
            }
            ,'json'
        );
    })

</script>
		</div>

	</div>
	<!--user box end-->
	<%--	公共底部	 --%>
	<jsp:include page="indexFooter.jsp" />
</body>
</html>